<!--
 * @FilePath     : /study_code/layui/18-1.html
 * @Description  : 快速渲染一个 tree 组件
 * @Date         : 2025-04-10 14:49:15
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-10 14:51:56
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
  </head>
  <body>
    <div id="test1"></div>

    <script src="/layui/dist/layui.js"></script>
    <!-- <script src="/layui/tree/common.js"></script> -->
    <script>
      layui.use('tree', function () {
        var tree = layui.tree

        //渲染
        var inst1 = tree.render({
          elem: '#test1', //绑定元素
          data: [
            {
              title: '江西', //一级菜单
              children: [
                {
                  title: '南昌', //二级菜单
                  children: [
                    {
                      title: '高新区', //三级菜单
                      //…… //以此类推，可无限层级
                    },
                  ],
                },
              ],
            },
            {
              title: '陕西', //一级菜单
              children: [
                {
                  title: '西安', //二级菜单
                },
              ],
            },
          ],
        })
      })
    </script>
  </body>
</html>
